Ext.define('Admin.view.system.job.Job', {
	extend: 'Admin.ux.PageGrid',
    xtype: 'job-view',
    title: '定时任务',
    viewModel: {
       stores: { 
	        data: {
	            type: 'job-store',
	            autoLoad: true
	   		 }
	    },
	    data:{
	    	batchRemoveAction : true,
	    	batchRemoveText:'批量删除(0)',
	    	batchPauseAction : true,
	    	batchPauseText:'暂停任务(0)',
	    	batchResumeAction : true,
	    	batchResumeText:'暂停任务(0)'
	    }
    },
    
    listeners: {
        selectionchange: 'onSelectionChange'
    },
    controller:'job',
	columnLines : false,
 	columns: [
	 	{ xtype: 'rownumberer',width:'7%'},
	 	{ text: '任务名', width:'35%',dataIndex: 'msg_title',flex:2,renderer:function(value, meta, record){
	 		if(value){
           	  meta.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(record.get('msg_content')) + '"';
    		}
	 		 return value;
	 	}}, 
	 	{ xtype:'gridcolumnview',width:'10%', text: '定时器表达式', dataIndex: 'cron'},
	 	{ xtype:'gridcolumnview',width:'12%', text: '执行时间', dataIndex: 'excute_time'}, 
	 	{ text: '状态', width:'7%',dataIndex: 'status',renderer:function(v){
	 		if(v=='0'){
	 			return "<font color='#1E90FF' >启动</font>";
	 		}else if(v=='3'){
	 			return "<font color='#32CD32' >执行成功</font>";
	 		}else if(v=='4'){
	 			return  "<font color='#EE0000' >执行失败</font>";
	 		}else{
	 			return  "<font color='#FFD700' >暂停</font>";
	 		}
	 		
	 	}}, 
	 	{ xtype:'hidden', dataIndex: 'create_time'}, 
	 	{ xtype:'gridcolumnview',width:'10%', text: '创建者', dataIndex: 'uid'},
	    {
	        menuDisabled: true,
	        sortable: false,
	        xtype: 'actioncolumn',
	        width:'10%',
	        text:'操作',
	        items: [
				{
				    iconCls: 'array-grid-buy-col',
				    tooltip: '编辑',
				    handler:'editAction'
				},
				'-',
				{
				    iconCls: 'array-grid-sell-col',
				    tooltip: '删除',
				    handler: 'removeAction'
				}
				]
	    }
	],
	
	plugins: [{
        ptype: 'rowexpander',
        rowBodyTpl : new Ext.XTemplate('<p>{msg_content}</p>',{})
    }],
    tbar:[
		{
			text:'批量删除',
			iconCls: 'x-fa fa-minus',
			handler:'batchRemoveAction',
			bind:{
				disabled :'{batchRemoveAction}',
				text:'{batchRemoveText}'
			}
		},
		{
			text:'暂停任务',
			iconCls: 'x-fa fa-plus',
			handler:'batchPauseAction',
			bind:{
    			disabled :'{batchPauseAction}',
    			text:'{batchPauseText}'
    		}
		},
		{
			text:'重启任务',
			iconCls: 'x-fa fa-plus',
			handler:'batchResumeAction',
			bind:{
    			disabled :'{batchResumeAction}',
    			text:'{batchResumeText}'
    		}
		},
		'->',
		{
			xtype : 'keysearchfield'
		}
	]
});
